import 'dart:math' as math;

import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/widgets.dart';

class XMFlutterUIInit {
  // ignore: non_constant_identifier_names
  static NavigatorObserver get navigatorObserver => BotToastNavigatorObserver();

  static TransitionBuilder get transitionBuilder => BotToastInit();
}

extension XMFlutterColor on Color {
  static get randomColor {
    math.Random random = math.Random();
    int r = random.nextInt(256) % 255;
    int g = random.nextInt(256) % 255;
    int b = random.nextInt(256) % 255;
    return Color.fromRGBO(r, g, b, 1.0);
  }

  static Color fromWhite(double white, {double alpha = 1.0}) {
    alpha = math.max(0.0, math.min(1.0, alpha));

    white = math.max(0.0, math.min(1.0, white));
    int rgb = (white * 255).toInt();
    return Color.fromRGBO(rgb, rgb, rgb, 1 - alpha);
  }
}
